package com.sailfish.springbootdemo.controller.db1;

import com.sailfish.springbootdemo.pojo.Result;
import com.sailfish.springbootdemo.pojo.db1.RoadmapBigType;
import com.sailfish.springbootdemo.pojo.db1.RoadmapSmallType;
import com.sailfish.springbootdemo.service.db1.RoadmapBigTypeService;
import com.sailfish.springbootdemo.service.db1.RoadmapSmallTypeService;
import com.sailfish.springbootdemo.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/roadmapSmallType")
@CrossOrigin
public class RoadmapSmallTypeController {

    @Autowired
    private RoadmapSmallTypeService roadmapSmallTypeService;

    @PostMapping("/getAllRoadmapSmallType")
    public Result getAllRoadmapSmallType(String searchValue, Integer roadmapBigTypeId) {
        try {
            return ResultUtil.success(roadmapSmallTypeService.getAllRoadmapSmallType(searchValue, roadmapBigTypeId));
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/deleteRoadmapSmallType")
    public Result deleteRoadmapSmallType(Integer roadmapSmallTypeId) {
        return roadmapSmallTypeService.deleteRoadmapSmallType(roadmapSmallTypeId);
    }

    @PostMapping("/addOrUpdateRoadmapSmallType")
    public Result addOrUpdateRoadmapSmallType(String mode, RoadmapSmallType roadmapSmallType) {
        return roadmapSmallTypeService.addOrUpdateRoadmapSmallType(mode, roadmapSmallType);
    }

    @PostMapping("/getAllRoadmapSmallTypeAndParam")
    public Result getAllRoadmapSmallTypeAndParam(Integer roadmapBigTypeId, Integer year, Integer versionY, String versionN) {
        return roadmapSmallTypeService.getAllRoadmapSmallTypeAndParam(roadmapBigTypeId, year, versionY, versionN);
    }

    @PostMapping("/getAllRoadmapSmallTypeAndParamCm")
    public Result getAllRoadmapSmallTypeAndParamCm(Integer roadmapBigTypeId, Integer pcbaCompanyId, Integer year, Integer versionY, String versionN) {
        return roadmapSmallTypeService.getAllRoadmapSmallTypeAndParamCm(roadmapBigTypeId, pcbaCompanyId, year, versionY, versionN);
    }

    @PostMapping("/getAllRoadmapSmallTypeAndParamH3c")
    public Result getAllRoadmapSmallTypeAndParamH3c(Integer roadmapBigTypeId, Integer year, Integer versionY, String versionN) {
        return roadmapSmallTypeService.getAllRoadmapSmallTypeAndParamH3c(roadmapBigTypeId, year, versionY, versionN);
    }

    @PostMapping("/getCmRoadmapByCompanyIdsAndBigTypeAndCalcCapacityIsMatch")
    public Result getCmRoadmapByCompanyIdsAndBigTypeAndCalcCapacityIsMatch(Integer roadmapBigTypeId, String pcbaCompanyIdsStr, Integer year, Integer versionY, String versionN) {
        return roadmapSmallTypeService.getCmRoadmapByCompanyIdsAndBigTypeAndCalcCapacityIsMatch(roadmapBigTypeId, pcbaCompanyIdsStr, year, versionY, versionN);
    }

    @PostMapping("/getCmRoadmapByCompanyIdsAndBigTypeAndCalcCapacityIsMatch2")
    public Result getCmRoadmapByCompanyIdsAndBigTypeAndCalcCapacityIsMatch2(Integer roadmapBigTypeId, String pcbaCompanyIdsStr, Integer year, Integer versionY, String versionN) {
        return roadmapSmallTypeService.getCmRoadmapByCompanyIdsAndBigTypeAndCalcCapacityIsMatch2(roadmapBigTypeId, pcbaCompanyIdsStr, year, versionY, versionN);
    }
}
